#pragma once
#include "DXContext.h"
#include "enums.h"
#include "D3DShape.h"

namespace DXBase
{
	namespace Samples
	{
		// Defines the vertex format for the shapes generated in the functions below.
		struct basicvertex
		{
			float3 pos;   // position
			float3 norm;  // surface normal vector
			float2 tex;   // texture coordinate
			color32 color; //

			basicvertex() 
			{
				color.a = color.r = color.g = color.b = 255;
			}
			basicvertex(float3& pos, float3& norm, float2& tex)
				: pos(pos), norm(norm), tex(tex)
			{
			}
			basicvertex(
				float posx, float posy, float posz,
				float normx, float normy, float normz, 
				float texu, float texv)
			{
				pos = vector3(posx, posy, posz);
				norm = vector3(normx, normy, normz);
				tex = vector2(texu, texv);
				color.a = color.r = color.g = color.b = 255;
			}
		};

		// this class contains various public WinRT utilities to load mesh data
		// and explicitly expose what the Vertex are made of
		[Windows::Foundation::Metadata::WebHostHidden]
		public ref class MeshLoader sealed
		{
		private:
			MeshLoader();
	
			static void BuildCylinderTopCap16(D3D::Shape^ mesh, float bottomRadius, float topRadius, float height, UINT sliceCount, UINT stackCount);
			static void BuildCylinderBottomCap16(D3D::Shape^ mesh, float bottomRadius, float topRadius, float height, UINT sliceCount, UINT stackCount);

			static void Subdivide32(D3D::Shape^ mesh, uint32& np, uint32& ni);
	public:

			static D3D::Shape^ CreateSphere16() { return CreateSphereMesh16(1, 40); }
			static D3D::Shape^ CreateSphereMesh16(float radius, UINT numticks);
			static D3D::Shape^ CreateCube16();
			static D3D::Shape^ CreateBox16(float3 radii);
			static D3D::Shape^ CreateReferenceAxis16();
			static D3D::Shape^ CreateCylinder16(float bottomRadius, float topRadius, float height, UINT sliceCount, UINT stackCount);


			static D3D::Shape^ CreateGrid32(float width, float depth, UINT m, UINT n);

			///<summary>
			/// Creates a geosphere centered at the origin with the given radius.  The
			/// depth controls the level of tessellation.
			///</summary>
			static D3D::Shape^ CreateGeosphere32(float radius, UINT numSubdivisions);

			static Windows::Foundation::IAsyncOperation<D3D::Shape^>^ LoadFrankLunaTextModel16(Platform::String^ filename);
		};

	}
}

